<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" %>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<html>
<head>
	<title><fmt:message code="sms.th.SendReminders"/></title>
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<link rel="stylesheet" type="text/css" href="../../lib/pagination/style/pagination.css"/>
	<link rel="stylesheet" type="text/css" href="../../css/base.css"/>
	<script src="/js/common/language.js"></script>
	<script src="../js/jquery/jquery-1.9.1.js" type="text/javascript" charset="utf-8"></script>
	<script src="../js/base/base.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../lib/laydate/laydate.js"></script>
	<script src="../../lib/pagination/js/jquery.pagination.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../../lib/laydate/laydate.js"></script>
	<script src="../../lib/layer/layer.js?20201106"></script>

	<style>
		html,body{
			width:100%;
			height:100%;
		}

		.countSpan {
			color: red;
		}

		.contentTableBody {
			text-align: center;
		}

		.reSend_a {
			color: dodgerblue;
			cursor: pointer;
		}

		.delete_a {
			color: #404060;
			cursor: pointer;
			display: inline-block;
			background: url(../../img/sms/icon_affairremind_delete_12.png) no-repeat;
			background-position-y: 7px;
			padding-right: 6px;
			padding-left: 22px;
			line-height: 25px;
			background-size: 17%;
		}

		.headTable tr {
			border: none;
		}

		table {
			width: 98%;
			margin: 0px 1%;
		}

		.contentTable thead tr {
			height: 50px;
			font-size: 14px;
		}

		label {
			cursor: pointer;
		}

		.contentTableBody tr {
			background: #F6F7F9;
		}

		.contentTableBody tr td {
			overflow: hidden;
			text-overflow: ellipsis;
			white-space: nowrap;
		}

		.contentTableBody tr:nth-child(even) {
			background: #ffffff;
		}

		.title_span {
			font-size: 16px;
		}

		.bottom_table {
			margin-top: -1px;
		}

		.bottom_table .first_td {
			background-color: #f2f2f2;
			border-right: 1px #dddddd solid;
			width: 80px;
		}

		.bottom_table a {
			cursor: pointer;
			margin-left: 10px;
			color: #404060;
			display: inline-block;
			padding-left: 22px;
			line-height: 25px;
			background: url(../../img/sms/icon_affairremind_delete_12.png) no-repeat;
			background-position-y: 7px;
			padding-right: 6px;
			background-size: 6%;
		}
		.title_span{
			margin-left: 5px;
		}
		.contentTableBody td{
			font-size: 11pt;
		}
		.imgDiv{
			text-align: center;
			display: none;
			margin-top: 60px;
		}
		.contentTable tr th{
			color: #2F5C8F;
			text-align: left;
			padding-left: 10px;
		}
		.contentTable tr td{
			text-align: left;
		}
		@media screen and (max-width:1366px){
			.txtContent{
				width: 300px;
			}
		}
		@media screen and (min-width:1367px){
			.txtContent{
				width: 540px;
			}
		}
		.btnTd{
			cursor: pointer;
		}
		.title_span~span{
			font-size: 12px;
		}
		#checkedAll+label{
			position: relative;
			top: 1px;
			right: -6px;
		}
	</style>
	<link rel="stylesheet" type="text/css" href="/css/commonTheme/${sessionScope.InterfaceModel}/commonTheme.css"/>
</head>
<body>

<table class="headTable">
	<tr>
		<td><img width="15px" height="15px" src="/img/commonTheme/${sessionScope.InterfaceModel}/title_send_sms.png" alt=""><span class="title_span"><fmt:message code="sms.th.SendReminders"/></span>&nbsp;&nbsp;<span>(<fmt:message code="main.th.general"/></span><span class="countSpan">0</span><span><fmt:message code="main.th.BarReminder"/>)</span>
		</td>
		<td></td>
		<td>
			<%--<div class="M-box3">--%>

			<%--</div>--%>
		</td>
	</tr>
</table>
<div class="imgDiv"><img class="noneImg" src="/img/main_img/shouyekong.png" alt="">
	<div>暂无数据</div>
</div>
<table class="contentTable" style="table-layout: fixed">
	<thead>
	<tr>
		<th style="width: 5%;min-width:50px;text-align: left"><fmt:message code="global.lang.select"/></th>
		<th style="width: 11%;"><fmt:message code="sms.th.Addressee"/></th>
		<th style="width: 12%;"><fmt:message code="notice.th.type"/></th>
		<th style="width: 40%;"><fmt:message code="notice.th.content"/></th>
		<th style="width: 20%;"><fmt:message code="sup.th.SendingTime"/></th>
		<th style="width: 6%;"><fmt:message code="notice.th.state"/></th>
		<th style="width: 6%;"><fmt:message code="notice.th.operation"/></th>
	</tr>
	</thead>
	<tbody class="contentTableBody">

	</tbody>
</table>

<table class="bottom_table" style="display: block;border: #ccc 1px solid;box-sizing: border-box;">
	<tr style="border: none;">
		<td class="first_td"><fmt:message code="news.th.Quickoperation"/>：</td>
		<td style="border-right: none;"><a class="delete_allRead"><fmt:message code="sms.th.DeleteReminders"/></a><a
				class="delete_toUserDeleted"><fmt:message code="sms.th.DeleteRecipient"/></a><a
		<td></td>
	</tr>
</table>
<div class="M-box3">

</div>

<script type="text/javascript">
	$(function () {

		var data = {
			queryType: 3,
			page: 1,
			pageSize: 10,
			useFlag: true
		};

		initPageList(function (pageCount) {
			initPagination(pageCount, data.pageSize);
		});

		function initPagination(totalData, pageSize) {
			$('.M-box3').pagination({
				totalData: totalData,
				showData: pageSize,
				jump: true,
				coping: true,
				current: data.page,
				homePage: '<fmt:message code="global.page.first" />',
				endPage: '<fmt:message code="global.page.last" />',
				prevContent: '<fmt:message code="global.page.pre" />',
				nextContent: '<fmt:message code="global.page.next" />',
				jumpBtn: '<fmt:message code="global.page.jump" />',
				callback: function (index) {
					data.page = index.getCurrent();

					initPageList(function (pageCount) {
						initPagination(pageCount, data.pageSize);
					});
				}
			});
		}

		function initPageList(cb) {

			$.ajax({
				type: "get",
				url: "<%=basePath%>sms/selectByQueryType",
				dataType: 'JSON',
				data: data,
				success: function (data) {

					var str = "";
					if (data.totleNum == 0) {
						parent.layer.msg("<fmt:message code="sms.th.noData" />");
						$(".imgDiv").css("display","block");
						$(".contentTable").css("display","none");
						$(".bottom_table").css("display","none");
						$(".M-box3").css("display","none");
						return
					}
					$(".imgDiv").css("display","none");
					$(".contentTable").css("display","block");
					$(".bottom_table").css("display","block");
					$(".M-box3").css("display","block");
					if(data.obj){
						for (var i = 0; i < data.obj.length; i++) {
							// 格式化时间
							var sendTime = new Date((data.obj[i].sendTime) * 1000).Format('yyyy-MM-dd');
							if (data.obj[i].toName == undefined) {
								data.obj[i].toName = "<fmt:message code="sms.th.UserNotExist" />";
							}
							var special = data.obj[i].content;
							var color='#2B7FE0'
							if (special.indexOf("紧急") != -1 || special.indexOf("特急") != -1) {
								color='red'
								// $(".txtContent").css("color","red");
							}

							str += "<tr><td  style='min-width:50px;text-align:left' ><input  class='checkChild'  type='checkbox' bodyId='" + data.obj[i].bodyId + "' name='check' value=''></td>" +
									"<td>" + data.obj[i].toName + "</td>" +
									"<td style=''>" + data.obj[i].smsTypeName + "</td>" +
									"<td class='btnTd' remindUrl='"+encodeURI(data.obj[i].remindUrl)+"'  bodyId='" + data.obj[i].bodyId + " title='" + data.obj[i].content + "'><div class='txtContent' style='color:"+color+";overflow: hidden;white-space: nowrap;text-overflow: ellipsis;'>" + data.obj[i].content + "</div></td>" +
									"<td style=''>" + data.obj[i].sendTimeStr + "</td>" +
									"<td>" + function () {
										if (data.obj[i].deleteFlag == 0) {
											if (data.obj[i].remindFlag == 0) {
												return "<fmt:message code="email.th.yiread" />";
											} else {
												return "<fmt:message code="email.th.unRead" />";
											}
										} else if (data.obj[i].deleteFlag == 1) {
											return "<fmt:message code="email.th.del" />";
										}
									}() + "</td>" +
									"<td>" + function () {
										if (data.obj[i].remindFlag == 0) {
											return "<a class='reSend_a' onclick='reSend()' bodyId='" + data.obj[i].bodyId + "' ><fmt:message code="email.th.chongxin" /></a>";
										} else {
											return "";
										}
									}() + "</td></tr>";
						}
					}


					var last_str = "<tr class='last_str'><td><input id='checkedAll'  type='checkbox' conid='29' name='check' value=''><label for='checkedAll'><fmt:message code="notice.th.allchose" /></label></td><td style='text-align: left;' colspan='2' class='btnStyle delete_check'><a class='delete_a'><fmt:message code="global.lang.delete" /></a></td><td class=''></td><td></td><td></td><td></td></tr>";

					if (data.totleNum != undefined) {
						$('.countSpan').html(" " + data.totleNum + " ");
					}

					$(".contentTableBody").html(str + last_str);


					if (cb) {
						cb(data.totleNum);
					}

					initPagination(data.totleNum, 10);
				}
			})
		}

		//点击全选
		$('.contentTableBody').on('click', '#checkedAll', function () {
//           alert('111');
			var state = $(this).prop("checked");
			if (state == true) {
				$(this).prop("checked", true);
				$(".checkChild").prop("checked", true);
			} else {
				$(this).prop("checked", false);
				$(".checkChild").prop("checked", false);
			}
		});

		//        点击内容查看详情
		$('.contentTableBody').on('click','.btnTd',function () {
			var remindUrl = $(this).attr("remindUrl");
			var bodyId = $(this).attr("bodyId");
			window.open('<%=basePath%>'+remindUrl);
		})

		// 删除
		$('.contentTableBody').on('click', '.delete_a', function () {
			var bodyIds = '';
			if ($('.checkchild:checked').size() == 0) {
				parent.layer.msg("<fmt:message code="sms.th.SelectLeastOneData" />", {icon: 0});
				return;
			}
			$('.checkchild:checked').each(function () {
				bodyIds += $(this).attr("bodyId") + ',';
			});
			$.ajax({
				type: "post",
				url: "<%=basePath%>sms/delete",
				dataType: 'JSON',
				data: {"bodyIds": bodyIds, "deleteFlag": "2",},
				success: function (res) {
					if (res.flag) {
						parent.layer.msg("<fmt:message code="workflow.th.delsucess" />", {icon: 1});
						initPageList(function (pageCount) {
							initPagination(pageCount, data.pageSize);
						});
					} else {
						parent.layer.msg("<fmt:message code="lang.th.deleSucess" />", {icon: 2});
					}
				}
			})
		});


		// 删除全部
		$('.delete_all').click(function () {
			$.ajax({
				type: "post",
				url: "<%=basePath%>sms/delete",
				dataType: 'JSON',
				data: {"deleteFlag": "2",},
				success: function (res) {
					if (res.flag) {
						parent.layer.msg("<fmt:message code="workflow.th.delsucess" />", {icon: 1});
						initPageList(function (pageCount) {
							initPagination(pageCount, data.pageSize);
						});
					} else {
						parent.layer.msg("<fmt:message code="lang.th.deleSucess" />", {icon: 2});
					}
				}
			})
		});

		// 删除收信人已删除
		$('.delete_toUserDeleted').click(function () {
			$.ajax({
				type: "post",
				url: "<%=basePath%>sms/deleteByDelFlag",
				dataType: 'JSON',
				success: function (res) {
					if (res.flag) {
						parent.layer.msg("<fmt:message code="workflow.th.delsucess" />", {icon: 1});
						initPageList(function (pageCount) {
							initPagination(pageCount, data.pageSize);
						});
					} else {
						parent.layer.msg("<fmt:message code="lang.th.deleSucess" />", {icon: 2});
					}
				}
			})
		});

		// 删除已提醒收信人提醒
		$('.delete_allRead').click(function () {
			$.ajax({
				type: "post",
				url: "<%=basePath%>sms/deleteByRemind",
				dataType: 'JSON',
				data: {"deleteType": "2"},
				success: function (res) {
					if (res.flag) {
						parent.layer.msg("<fmt:message code="workflow.th.delsucess" />", {icon: 1});
						initPageList(function (pageCount) {
							initPagination(pageCount, data.pageSize);
						});
					} else {
						parent.layer.msg("<fmt:message code="lang.th.deleSucess" />", {icon: 2});
					}
				}
			})
		});

		//重新发送
		$('.contentTableBody').on('click', '.reSend_a', function () {
			var bodyId = $('.reSend_a').attr("bodyId");
			$.ajax({
				type: "post",
				url: "<%=basePath%>sms/updateRemind",
				dataType: 'JSON',
				data: {"bodyIds": bodyId, "remindFlag": "1",},
				success: function (res) {
					if (res.flag) {
						parent.layer.msg("<fmt:message code="email.th.alRead" />", {icon: 1});
						initPageList(function (pageCount) {
							initPagination(pageCount, data.pageSize);
						});
					} else {
						parent.layer.msg("<fmt:message code="email.th.filed" />", {icon: 2});
					}
				}
			})
		});


	});

</script>
</body>
</html>
